﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace Gama.Extension
{
    public static partial class ViewUserControlExtensions
    {
        public static CheckBoxBuilder<TModel> CheckBoxEx<TModel>(this ViewUserControl<TModel> viewUserControl, Expression<Func<TModel, object>> expression)
            where TModel : class
        {
            return viewUserControl.Html.CheckBoxEx(expression);
        }

        public static DropDownListBuilder<TModel, TItem> DropDownListEx<TModel, TItem>(this ViewUserControl<TModel> viewUserControl, Expression<Func<TModel, object>> expression, IEnumerable<TItem> selectList)
             where TModel : class
        {
            return viewUserControl.Html.DropDownListEx(expression, selectList);
        }

        public static RadioButtonBuilder<TModel> RadioButtonEx<TModel>(this ViewUserControl<TModel> viewUserControl, Expression<Func<TModel, object>> expression)
            where TModel : class
        {
            return viewUserControl.Html.RadioButtonEx(expression);
        }

        public static TextBoxBuilder<TModel> TextBoxEx<TModel>(this ViewUserControl<TModel> viewUserControl, Expression<Func<TModel, object>> expression)
             where TModel : class
        {
            return viewUserControl.Html.TextBoxEx(expression);
        }

        public static TextAreaBuilder<TModel> TextAreaEx<TModel>(this ViewUserControl<TModel> viewUserControl, Expression<Func<TModel, object>> expression)
             where TModel : class
        {
            return viewUserControl.Html.TextAreaEx(expression);
        }

        public static PasswordBuilder<TModel> PasswordEx<TModel>(this ViewUserControl<TModel> viewUserControl, Expression<Func<TModel, object>> expression)
            where TModel : class
        {
            return viewUserControl.Html.PasswordEx(expression);
        }

        public static HiddenBuilder<TModel> HiddenEx<TModel>(this ViewUserControl<TModel> viewUserControl, Expression<Func<TModel, object>> expression)
            where TModel : class
        {
            return viewUserControl.Html.HiddenEx(expression);
        }

        public static ValidationMessageBuilder<TModel> ValidationMessageEx<TModel>(this ViewUserControl<TModel> viewUserControl, Expression<Func<TModel, object>> expression)
            where TModel : class
        {
            return viewUserControl.Html.ValidationMessageEx(expression);
        }

        public static ActionLinkBuilder<TController> ActionLinkEx<TController>(this ViewUserControl viewUserControl, Expression<Func<TController, ActionResult>> expression)
            where TController : Controller
        {
            return viewUserControl.Html.ActionLinkEx(expression);
        }

        public static void RenderPartialEx<TModel>(this ViewUserControl<TModel> viewUserControl, string partialViewName, Expression<Func<TModel, object>> expression)
            where TModel : class
        {
            using (viewUserControl.Html.BeginBindingSection(expression))
            {
                viewUserControl.Html.RenderPartial(partialViewName, expression.Compile()(viewUserControl.Model));
            }
        }
    }
}
